package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.service.FindDnameService;
import com.jx.servicrimpl.FindDnameServiceImpl;
/**
 * 查询部门名是否存在
 * @author zzzzzzz
 *
 */
public class FindDnameController extends HttpServlet{
	FindDnameService fds=new FindDnameServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("UTF8");
		resp.setCharacterEncoding("UTF8");
		//获取部门名
		String dname=req.getParameter("dname");
		//调用方法传回数据
		PrintWriter pw=resp.getWriter();
		if(fds.findDnameService(dname)==true){
			pw.write("1");
		}else{
			pw.write("0");
		}
		
	}
}
